package com.loan.market.view

import android.content.Context
import android.util.AttributeSet
import com.loan.market.R
import com.scwang.smart.refresh.layout.SmartRefreshLayout

class RefreshView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) : SmartRefreshLayout(context, attrs) {

    init {
        setDragRate(1f)
        setEnableAutoLoadMore(false)
        setEnableOverScrollDrag(false)
        setEnableOverScrollBounce(false)
        setRefreshHeader(RefreshHeader(context))
        setRefreshFooter(BallPulseFooter(context).apply {
            setAnimatingColor(getContext().getColor(R.color.color_accent))
            setNormalColor(getContext().getColor(R.color.color_accent))
        })
    }

    fun finish(success: Boolean = true) {
        if (isRefreshing) {
            finishRefresh(success)
        }
        if (isLoading) {
            finishLoadMore(success)
        }
    }

}